<template>
  <div>
    <index-cmpt :models="models"></index-cmpt>
    <submit-edit-dialog
      :visible.sync="submitVisible"
      @success="handleSubmitSuccess"
      :product-id="productId"
      @dismiss="handleClose"
    ></submit-edit-dialog>
  </div>
</template>

<script>
import IndexCmpt from '@/bank/views/business/28/normal/IndexCmpt'
import { mapGetters } from 'vuex'
import SubmitEditDialog from '@/bank/views/business/limit/history/submit/SubmitEditDialog'
export default {
  components: {
    SubmitEditDialog,
    IndexCmpt,
  },
  data() {
    return {
      submitVisible: false,
      refStatus: 1,
    }
  },
  computed: {
    ...mapGetters(['taskCountLimit']),
    productId() {
      return this.$route.query.id
    },
    models() {
      return [
        {
          title: '项目导入',
          subTitle: '异常',
          subCount: this.taskCountLimit.todo_exc_total || 0,
          url: '/res_index/limit/limit12/list/import',
        },
        {
          title: '项目申报',
          subTitle: '待办',
          subCount: this.taskCountLimit.todo_apply_total || 0,
          subUrl: 'task',
          url: '/res_index/limit/limit12/list/submit/',
        },
        {
          title: '项目确认',
          subTitle: '待办',
          subCount: this.taskCountLimit.todo_confirm_total || 0,
          subUrl: 'task',
          url: '/res_index/limit/limit12/list/confirm/',
        },
        {
          title: '资料补充',
          subTitle: '待办',
          subCount: this.taskCountLimit.todo_datum_total || 0,
          subUrl: 'task',
          url: '/res_index/limit/limit12/list/attach/',
        },
        {
          title: '贷后管理',
          subTitle: '到期',
          subCount: this.taskCountLimit.todo_exp_total || 0,
          subUrl: 'expire',
          url: '/res_index/limit/limit12/list/postloan/',
        },
      ]
    },
  },
  created() {
    this.$store.dispatch('getTaskCountLimit', { type: 0, id: this.productId })
  },
  methods: {
    showSubmitDiaog() {
      this.submitVisible = true
    },
    handleClose() {
      this.submitVisible = false
    },
    handleSubmitSuccess() {
      this.$router.push({
        path: '/res_index/limit/limit12/list/submit',
        query: {
          id: this.productId,
          status: this.refStatus++,
        },
      })
    },
  },
}
</script>
<style lang="scss" scoped></style>
